﻿<Window x:Class="SharePointSearchBench.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="SharePoint Search Bench" Style="{DynamicResource window}" Height="800" Width="800" MinWidth="800" MinHeight="800">
	<Window.CommandBindings>
		<CommandBinding Command="ApplicationCommands.Open"
						Executed="OpenCommandExecuted"/>
		<CommandBinding Command="ApplicationCommands.Save"
						Executed="SaveCommandExecuted"/>
		<CommandBinding Command="ApplicationCommands.SaveAs"
						Executed="SaveAsCommandExecuted"/>
		<CommandBinding Command="ApplicationCommands.Close"
						Executed="CloseCommandExecuted"/>
	</Window.CommandBindings>
	<Window.Resources>



	</Window.Resources>

	<Grid Style="{DynamicResource mainGrid}">
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
			<RowDefinition/>
		</Grid.RowDefinitions>

		<Grid Grid.Row="1">

			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="300"/>
				<ColumnDefinition/>
			</Grid.ColumnDefinitions>

			<StackPanel VerticalAlignment="Stretch" Grid.Column="0">

				<GroupBox Header="Connection Type" MinWidth="150" Template="{StaticResource groupBoxContainer}">
					<StackPanel>
						<WrapPanel Orientation="Horizontal">
							<RadioButton Style="{DynamicResource radioButtonStyle}" IsChecked="True" x:Name="objectModelButton" Checked="ObjectModelButtonChecked">Object Model</RadioButton>
							<RadioButton Style="{DynamicResource radioButtonStyle}" x:Name="webServiceButton" Checked="WebServiceButtonChecked">Web Service</RadioButton>
						</WrapPanel>
						<StackPanel Visibility="Visible" x:Name="webServiceConnectionPanel">
							<StackPanel>
								<TextBlock>Service or Site Url:</TextBlock>
								<ComboBox IsEnabled="True" Style="{DynamicResource stackedComboBox}" x:Name="webServiceUrlComboBox" IsReadOnly="False" IsEditable="True" SelectionChanged="ControlChanged"/>
							</StackPanel>

							<StackPanel>
								<TextBlock>Domain:</TextBlock>
								<ComboBox IsEnabled="False" Style="{DynamicResource stackedComboBox}" x:Name="domainComboBox" IsReadOnly="False" IsEditable="True" SelectionChanged="ControlChanged"/>
							</StackPanel>

							<StackPanel>
								<TextBlock IsEnabled="False">Username:</TextBlock>
								<ComboBox IsEnabled="False" Style="{DynamicResource stackedComboBox}" x:Name="usernameComboBox" IsReadOnly="False" IsEditable="True" SelectionChanged="ControlChanged"/>
							</StackPanel>

							<StackPanel>
								<TextBlock IsEnabled="False">Password:</TextBlock>
								<PasswordBox IsEnabled="False" Style="{DynamicResource stackedPasswordBox}" x:Name="passwordTextBox" PasswordChanged="ControlChanged"/>
							</StackPanel>

						</StackPanel>
					</StackPanel>
				</GroupBox>

				<Border Style="{DynamicResource containerBorderStyle}">
					<StackPanel>
						<Label Style="{DynamicResource smallHeadingLabel}">Scopes</Label>
						<ListBox Height="100"
			x:Name="scopesListBox"
			ScrollViewer.CanContentScroll="True"
			ScrollViewer.VerticalScrollBarVisibility="Visible"
			ScrollViewer.HorizontalScrollBarVisibility="Auto"
			VerticalAlignment="Stretch"/>
					</StackPanel>
				</Border>

				<Border Style="{DynamicResource containerBorderStyle}">
					<StackPanel>
						<Label Style="{DynamicResource smallHeadingLabel}">Managed Properties</Label>
						<ListBox Height="100"
							x:Name="managedPropertiesListBox"
							ScrollViewer.CanContentScroll="True"
							ScrollViewer.VerticalScrollBarVisibility="Visible"
							ScrollViewer.HorizontalScrollBarVisibility="Auto"
							VerticalAlignment="Stretch"/>
					</StackPanel>
				</Border>



				<Button HorizontalAlignment="Right" Click="RefreshMetadataClick" x:Name="refreshMetadataButton" VerticalAlignment="Center">Refresh Scopes and Properties</Button>






			</StackPanel>

			<Grid Grid.Column="1">

				<Grid.RowDefinitions>

					<RowDefinition Height="Auto"/>
					<RowDefinition/>
				</Grid.RowDefinitions>

				<StackPanel VerticalAlignment="Stretch" Grid.Row="0">

					<GroupBox Header="Options" Template="{StaticResource groupBoxContainer}">

						<WrapPanel Orientation="Horizontal">
							<WrapPanel Orientation="Horizontal">
								<RadioButton Style="{DynamicResource radioButtonStyle}" IsChecked="True" x:Name="fullTextButton" Checked="QueryTypeButtonChecked">Full Text</RadioButton>
								<RadioButton Style="{DynamicResource radioButtonStyle}" x:Name="keywordButton" Checked="QueryTypeButtonChecked">Keyword</RadioButton>
							</WrapPanel>
							<WrapPanel Orientation="Horizontal">
								<Label VerticalAlignment="Center" Target="{Binding ElementName=numberOfResultsTextBox}">Start At:</Label>
								<TextBox Style="{DynamicResource textBox}" Width="50" TextAlignment="Right" x:Name="startAtTextBox" VerticalAlignment="Center" Height="Auto" TextChanged="ControlChanged">1</TextBox>
								<Label VerticalAlignment="Center" Target="{Binding ElementName=numberOfResultsTextBox}"># of _Results:</Label>
								<TextBox Style="{DynamicResource textBox}" Width="50" TextAlignment="Right" x:Name="numberOfResultsTextBox" VerticalAlignment="Center" Height="Auto" TextChanged="ControlChanged">100</TextBox>
							</WrapPanel>
						</WrapPanel>

					</GroupBox>
					<GroupBox Header="Result Type" Template="{StaticResource groupBoxContainer}">
						<WrapPanel Orientation="Horizontal">
							<RadioButton Style="{DynamicResource radioButtonStyle}" IsChecked="True" x:Name="relevantResultsButton">Relevant</RadioButton>
							<RadioButton Style="{DynamicResource radioButtonStyle}" IsChecked="False" x:Name="highConfidenceResultsButton">High Confidence</RadioButton>
							<RadioButton Style="{DynamicResource radioButtonStyle}" IsChecked="False" x:Name="specialTermsResultsButton">Special Terms</RadioButton>
						</WrapPanel>

					</GroupBox>

					<Border Style="{DynamicResource containerBorderStyle}" x:Name="fullTextBorder">
						<StackPanel>
							<Label Style="{DynamicResource smallHeadingLabel}" Target="{Binding ElementName=queryTextBox}">Query _Text</Label>
							<TextBox x:Name="queryTextBox" Style="{DynamicResource queryTextBox}" AcceptsReturn="True" Height="100" TextWrapping="Wrap" TextChanged="ControlChanged">select title, author, rank from scope() where freetext(defaultproperties, 'sharepoint') order by rank</TextBox>
						</StackPanel>
					</Border>

					<Border x:Name="keywordPhraseBorder" Style="{DynamicResource containerBorderStyle}" Visibility="Collapsed">
						<StackPanel>
							<Label Style="{DynamicResource smallHeadingLabel}" Target="{Binding ElementName=queryTextBox}">Keyword Query Text:</Label>
							<TextBox x:Name="keywordPhraseTextBox" Style="{DynamicResource textBox}" TextChanged="ControlChanged">sharepoint</TextBox>
						</StackPanel>
					</Border>
					<Border x:Name="keywordFieldsBorder" Style="{DynamicResource containerBorderStyle}" Visibility="Collapsed">
						<StackPanel>
							<Label Style="{DynamicResource smallHeadingLabel}" Target="{Binding ElementName=queryTextBox}">Keyword Query Display Fields (comma-separated):</Label>
							<TextBox x:Name="keywordFieldsTextBox" Style="{DynamicResource textBox}" TextChanged="ControlChanged">Title, Description, Author, Rank</TextBox>
						</StackPanel>
					</Border>
					<Border x:Name="keywordSortFieldsBorder" Style="{DynamicResource containerBorderStyle}" Visibility="Collapsed">
						<StackPanel>
							<Label Style="{DynamicResource smallHeadingLabel}" Target="{Binding ElementName=queryTextBox}">Keyword Query Sort Fields (comma-separated):</Label>
							<TextBox x:Name="keywordSortFieldsTextBox" Style="{DynamicResource textBox}" TextChanged="ControlChanged">Rank, Author</TextBox>
						</StackPanel>
					</Border>

					<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
						<Button VerticalAlignment="Center" HorizontalAlignment="Right" Width="100" x:Name="executeButton" Click="ExecuteButtonClick">Execute</Button>
					</StackPanel>

				</StackPanel>

				<Grid Grid.Row="1">
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto"/>
						<RowDefinition/>
					</Grid.RowDefinitions>
					<StackPanel Grid.Row="0">

						<Border VerticalAlignment="Bottom" Style="{DynamicResource containerBorderStyle}">
							<StackPanel>
								<TextBlock Style="{DynamicResource smallHeading}" Margin="0,0,0,5" Text="Information"/>
								<TextBox x:Name="errorTextBox" ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Auto" TextWrapping="Wrap" Padding="10" Foreground="Red" Background="Transparent" BorderThickness="1" BorderBrush="Black" Height="200" IsReadOnly="True" Visibility="Collapsed"/>
								<TextBlock x:Name="infoTextBlock" TextWrapping="Wrap" Visibility="Visible"/>
							</StackPanel>
						</Border>

						<Border VerticalAlignment="Bottom" Style="{DynamicResource containerBorderStyle}" x:Name="queryXmlBorder" Visibility="Collapsed">
							<StackPanel>
								<Label Style="{DynamicResource smallHeadingLabel}">Actual Query Xml:</Label>
								<TextBox x:Name="queryXmlTextBox" Style="{DynamicResource queryTextBox}" IsReadOnly="True" ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Auto" AcceptsReturn="True" Height="200" TextWrapping="Wrap"/>
							</StackPanel>
						</Border>


					</StackPanel>
					<ListView Margin="10" Grid.Row="1"
		   ScrollViewer.CanContentScroll="True"
		   ScrollViewer.HorizontalScrollBarVisibility="Visible"
		   ScrollViewer.VerticalScrollBarVisibility="Auto"
		   x:Name="resultsListView"
			VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
						<ListView.View>
							<GridView x:Name="resultsGridView">
							</GridView>
						</ListView.View>
					</ListView>

				</Grid>


			</Grid>

		</Grid>

		<Menu Grid.Row="0">
			<MenuItem Header="File" Style="{DynamicResource topLevelMenuItem}">
				
				<MenuItem Header="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}" Command="Open">
					
				</MenuItem>
				<MenuItem Header="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}" Command="SaveAs">
					
				</MenuItem>
				<MenuItem Header="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}" Command="Save">
					
				</MenuItem>
				<Separator />
				<MenuItem Header="Recent Files" x:Name="recentFilesMenuItem" ItemsSource="{Binding Source={StaticResource recentFilesSource}}" Click="RecentFileMenuItemClick">
					
				</MenuItem>
				<Separator />
				<MenuItem Header="E_xit" Command="Close">
					
				</MenuItem>
			</MenuItem>

			<MenuItem Header="Help" Style="{DynamicResource topLevelMenuItem}">
				<MenuItem Header="About" Click="AboutClick">
				</MenuItem>
			</MenuItem>
		</Menu>

	</Grid>

</Window>
